// 这里面专门写和用户操作相关的api函数
import http from './http'
export const loginApi = (params: ILoginParams): RSP<ILoginResult> => http.post('/admin/login', params)

// 获取登录后的用户的信息(菜单之类的)
export const userInfoApi = (): RSP<IUserInfo> => http.get('/admin/info')

export const userListDataApi = (params: IUserListParams, token: any): RSP<IUserListData> => http.get('/admin/list', { params, cancelToken: token })

export const addUserApi = (params: IAddUserParams): RSP<any> => http.post('admin/register', params)

export const getUserInfoByIdApi = (id: number): RSP<IUserModel> => http.get(`/admin/${id}`)

export const updateUserInfoApi = (params: IUserModel): RSP<any> => http.post(`/admin/update/${params.id}`, params)

export const disabledUserApi = (id: number, status: 0 | 1): RSP<any> => http.post(`/admin/updateStatus/${id}?status=${status}`,)

export const getUserRoleIdsByAdminIdApi = (id: number): RSP<IRoleModel[]> => http.get(`/admin/role/${id}`)

export const allocUserRoleApi = (params: { adminId: number, roleIds: number[] }): RSP<any> => http.post(`/admin/role/update?adminId=${params.adminId}&roleIds=${params.roleIds.join(',')}`)